package com.qzdatasoft.mcp.server.common;

import io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification;
import io.modelcontextprotocol.server.McpSyncServerExchange;
import io.modelcontextprotocol.spec.McpSchema.GetPromptRequest;
import io.modelcontextprotocol.spec.McpSchema.GetPromptResult;
import io.modelcontextprotocol.spec.McpSchema.Prompt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.BiFunction;

public abstract class AbstractPromptProvider implements IMcpProvider {
    Logger log = LoggerFactory.getLogger(AbstractPromptProvider.class);

    abstract protected Prompt getMeta();

    abstract protected BiFunction<McpSyncServerExchange, GetPromptRequest, GetPromptResult> handler();

    @Override
    public ProviderType getType() {
        return ProviderType.PROMPT;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        SyncPromptSpecification promptSpecification= new SyncPromptSpecification(getMeta(), handler());
        McpFactory.getSyncPromptSpecificationList().add(promptSpecification);
        log.info("{} initialized.",  this.getClass().getName());
    }
}
